#include "mylabel.h"
#include <QMouseEvent>
#include <QDebug>
#include <QEvent>

MyLabel::MyLabel(QWidget *parent)
    :QLabel(parent)
{
}

void MyLabel::mouseMoveEvent(QMouseEvent *ev)
{
    QString pos = QString("鼠标按下， x=%1 y=%2").arg(ev->x()).arg(ev->y());
    qDebug() << pos.toUtf8().data();
}

bool MyLabel::event(QEvent *e)
{
    if(e->type() == QEvent::MouseButtonPress)
    {
        QMouseEvent* event = static_cast<QMouseEvent *>(e);
        QString pos = QString("鼠标按下， x=%1 y=%2").arg(event->x()).arg(event->y());
        qDebug() << pos.toUtf8().data();

        return true;
    }

   return QWidget::event(e);
}
